using System;
using System.ComponentModel.DataAnnotations;
using SqlSugar;

namespace twistmachinev2.Entity
{
    /// <summary>
    /// OPCUA服务器配置实体
    /// </summary>
    [SugarTable("OpcUaServerConfig")]
    public class OpcUaServerConfigEntity
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 服务器URL
        /// </summary>
        [SugarColumn(Length = 500)]
        public string ServerUrl { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = true)]
        public string Username { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = true)]
        public string Password { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; set; } = true;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(Length = 500, IsNullable = true)]
        public string Remark { get; set; }
    }

    /// <summary>
    /// OPCUA节点配置实体
    /// </summary>
    [SugarTable("OpcUaNodeConfig")]
    [SugarIndex("unique_PropertyName", nameof(OpcUaNodeConfigEntity.PropertyName), OrderByType.Asc, true)]
    public class OpcUaNodeConfigEntity
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 节点ID
        /// </summary>
        [SugarColumn(Length = 200)]
        public string NodeId { get; set; }

        /// <summary>
        /// 节点名称
        /// </summary>
        [SugarColumn(Length = 100)]
        public string Name { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [SugarColumn(Length = 500, IsNullable = true)]
        public string Description { get; set; }

        /// <summary>
        /// 数据类型
        /// </summary>
        [SugarColumn(Length = 50)]
        public string DataType { get; set; }

        /// <summary>
        /// 访问级别
        /// </summary>
        [SugarColumn(Length = 50)]
        public string AccessLevel { get; set; } = "Read";

        /// <summary>
        /// 扫描频率(毫秒)
        /// </summary>
        public int ScanRate { get; set; } = 1000;

        /// <summary>
        /// 是否订阅
        /// </summary>
        public bool IsSubscribed { get; set; } = false;

        /// <summary>
        /// 属性名称
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = true)]
        public string PropertyName { get; set; }

        /// <summary>
        /// 对象名称
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = true)]
        public string ObjectName { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        [SugarColumn(Length = 100, IsNullable = true)]
        public string Group { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; set; } = true;

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; } = 0;

        /// <summary>
        /// 写入功能
        /// </summary>
        public int WriteFunction { get; set; } = 0;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(Length = 500, IsNullable = true)]
        public string Remark { get; set; }
    }
}